<script setup>
import HomePanel from "./HomePanel.vue";
import { getHotInfo } from "@/apis/home.js";
import { ref, onMounted } from "vue";

const hotList = ref([]);
const getHot = async () => {
  const res = await getHotInfo();
  hotList.value = res.result;
};
onMounted(() => {
  getHot();
});
</script>

<template>
  <HomePanel title="人气推荐" subTitle="人气推荐 好多商品">
    <ul class="content">
      <li v-for="hot in hotList" :key="hot.id">
        <RouterLink :to="`/detail/${hot.id}`">
          <img v-img-lazy="hot.picture" alt="" />
          <p class="title">{{ hot.title }}</p>
          <p class="alt">{{ hot.alt }}</p>
        </RouterLink>
      </li>
    </ul>
  </HomePanel>
</template>

<style scoped lang="scss">
.content {
  display: flex;
  justify-content: space-between;
  height: 406px;

  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    transition: all 0.5s;

    &:hover {
      transform: translate3d(0, -3px, 0);
      box-shadow: 0 3px 8px rgb(0 0 0 / 20%);
    }

    img {
      width: 306px;
      height: 306px;
    }
    p {
      padding-top: 12px;
      font-size: 22px;
      text-align: center;
    }
    .alt {
      font-size: 17px;
      opacity: 0.5;
    }
  }
}
</style>
